package com.apes.fn.fico.debitnote.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 借支利息明细
 * Creator: zouyc
 * CreateDate: 2019-12-20 11:52
 * Description:
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = DebitRate.CONST_TABLE_NAME)
public class DebitRate extends Model {
    public static final String CONST_TABLE_NAME = "fn_debitrate";

    @Id
    @Column(name = "id", length = 30)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "借支利息明细编码", padding = 10)
    @Comment("借支利息明细编码")
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "business_debit_note_id", referencedColumnName = "id", nullable = false)
    @Comment("借支单号")
    private BusinessDebitNote businessDebitNote;

    @Column(name = "capital_balance", columnDefinition = "NUMBER(16,2) DEFAULT 0")
    @Comment("本金余额")
    private double capitalBalance = 0.0;

    @Column(name = "annual_rate", columnDefinition = "NUMBER(8,4) DEFAULT 0")
    @Comment("年利率")
    private double annualRate = 0.0;

    @Column(name = "today_interest", columnDefinition = "NUMBER(16,2) DEFAULT 0")
    @Comment("本日利息")
    private double todayInterest = 0.0;

    @Column(name = "interest_balance", columnDefinition = "NUMBER(16,2) DEFAULT 0")
    @Comment("利息余额")
    private double interestBalance = 0.0;
}
